package com.wm.exam.service.impl;

import com.wm.exam.dao.ExamHistoryMapper;
import com.wm.exam.pojo.ExamHistory;
import com.wm.exam.pojo.User;
import com.wm.exam.service.ExamHistoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class ExamHistoryServiceImpl implements ExamHistoryService {
    @Autowired
    private ExamHistoryMapper examHistoryMapper;

    /**
     * 添加考试历史
     * @param user
     * @param answer
     * @param categoryId
     * @param scope
     * @return
     */
    @Override
    public int addHistory(User user, String answer, String categoryId, double scope) {
        ExamHistory history = new ExamHistory();
        history.setCommitAnswer(answer);
        history.setPaperId(categoryId);
        history.setScope(scope);
        history.setStatus(1);
        history.setStuNum(user.getStuNum());
        return examHistoryMapper.insertSelective(history);
    }

    /**
     * 查询用户的考试记录
     * @param stuNum
     * @param uuid
     * @return
     */
    @Override
    public ExamHistory getByUUIDAndStuNum(Integer stuNum, String uuid) {
        return examHistoryMapper.getByUUIDAndStuNum(stuNum, uuid);
    }
}
